package com.zyy.middleware.exception;

import org.springframework.http.HttpStatus;

/**
 * @author zhangyangyang
 * @createTime 2023417 14:22
 * @description 自定义异常类型
 */
public enum ErrorCode {

    UN_KENOWN(1001, HttpStatus.BAD_REQUEST, "未未知异常"),
    RESOURCE_NOT_FOUND(1001, HttpStatus.NOT_FOUND, "未找到该资源"),
    REQUEST_VALIDATION_FAILED(1002, HttpStatus.BAD_REQUEST, "请求数据格式验证失败"),
    USER_NOT_FOUND(1003, HttpStatus.NO_CONTENT, "用户信息不存在");

    private final int code;

    private final HttpStatus status;

    private final String message;

    ErrorCode(int code, HttpStatus status, String message) {
        this.code = code;
        this.status = status;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public HttpStatus getStatus() {
        return status;
    }

    public String getMessage() {
        return message;
    }

    @Override
    public String toString() {
        return"ErrorCode{" +
            "code=" + code +
            ", status=" + status +
            ", message='" + message + '\'' +
            '}';
    }
}
